package MawsonClient.GUI;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

/**
 * User: Ryan Green
 * Date: 12/1/11
 * Time: 9:01 PM
 * Copyright - University of South Australia
 */
public class PerLinePanel extends JPanel {
	MawsonFrame frame;

	PerLinePanel(MawsonFrame frame){
		super();

		this.frame = frame;

		//per line panel
		this.setLayout(new CardLayout());

		int counter = 0;

		for (ArrayList<RequestedDataElement> list : frame.perLineElements) {
			JPanel centrePanel = new JPanel(new GridLayout(0, 2, 5, 5));
			centrePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Per Entry Data"));

			for (RequestedDataElement element : list) {
				centrePanel.add(new JLabel(element.label));
				centrePanel.add(element.comp);
			}
			JPanel holdingPanel = new JPanel(new BorderLayout());
			holdingPanel.add(new JLabel(" "), BorderLayout.CENTER);
			holdingPanel.add(centrePanel, BorderLayout.NORTH);
			this.add(holdingPanel, Integer.toString(counter));
			counter++;
		}
	}
}
